import string
from random import random

from django.test import TestCase

# Create your tests here.
from paginator_study.models import Student


@classmethod
def insert_test_data(cls, num=100):
    def random_str(raw_ite, length):
        return ''.join(random.choices(raw_ite, k=length))

    obj_list = []
    for _ in range(num):
        obj_list.append(Student(
            name=random_str(string.ascii_lowercase, 8),
            age=random.randint(18, 50),
            sex=random.choice([1, 2]),
            card_no=random_str(string.digits, 18)
        ))

    Student.objects.bulk_create(obj_list)